<% content_for :head do %>
  <%= tag.meta property: "og:type", content: "website" %>
  <%= tag.meta name: "description", content: truncate(sanitize(@collection.caption), length: 80) if @collection.caption.present? %>
  <%= tag.link rel: "alternate", type: Mime[:oembed], href: collection_url(@collection, format: :oembed), title: @collection.name %>
<% end %>

<%= content_for :items do %>
  <%= turbo_stream_from @collection %>
  <div class="card mb-3 <%= "remote-actor" if @collection.remote? %>">
    <div class="card-header"><%= @collection.model_name.human %></div>
    <div class="card-body row">
      <div class="col col-auto">
        <%= content_tag(:div, class: "text-center") do %>
          <h2>
            <%= @collection.name %>
          </h2>
          <p>
            <% if @collection.remote? %>
              <small class="text-secondary"><%= link_to @collection.federails_actor.at_address, @collection.federails_actor.profile_url, target: "new" %></small>
            <% elsif SiteSettings.federation_enabled? %>
              <small class="text-secondary">
                <%= CopyableText(text: @collection.federails_actor.at_address, label: t("general.copy_fediverse_handle")) %>
              </small>
            <% end %>
          </p>
          <%= FollowButton(follower: current_user, target: @collection) %>
        <% end %>
      </div>
      <div class="col">
        <%= content_tag(:p, class: "lead") { @collection.caption } if @collection.caption %>
        <%= content_tag(:p, class: "card-text") { markdownify @collection.notes } if @collection.notes %>
        <% model_count = policy_scope(Model).where(collection: @collection).count %>
        <p><%= "#{model_count} #{Model.model_name.human count: model_count}" %></p>
        <%= content_tag(:p) { t("general.followers", count: @collection.followers.count) } if SiteSettings.social_enabled? %>
        <p><%= AccessIndicator(object: @collection, text: true) %></p>
      </div>
      <div class="col col-auto">
        <%= render "attribution", collection: @collection %>
        <%= LinkList links: @collection.links %>
      </div>
    </div>
  </div>
<% end %>

<% content_for :actions do %>
  <%= link_to safe_join([Icon(icon: "pencil", label: t(".edit")), t(".edit")], " "), edit_collection_path(@collection), class: "btn btn-primary" if policy(@collection).edit? %>
  <%= ReportButton(object: @collection, path: new_collection_report_path(@collection)) %>
<% end %>

<%= render "models/list" %>
